package com.itheima.web;

import com.itheima.Service.UserService;
import com.itheima.dao.pojo.User;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/queryAllUserServlet")
public class QueryAllUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //调用Service中的cx类中的方法查询用户
        UserService userService = new UserService();

        //获取结果list集合
        List<User> user = userService.getUser();
        //将list集合传到session域中
        request.getSession().setAttribute("UserList",user);
        //转发到list.jsp(查询)的页面
        request.getRequestDispatcher("list.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
